import 'dart:convert';

import 'package:flutter_wgtool/OSNet/Request/BaseRequest.dart';

abstract class OSNetAdapter {
  Future<OSNetResponse<T>> send<T>(BaseRequest request);
}

/// 统一网络层返回格式
class OSNetResponse<T> {
  T? data;
  BaseRequest request;
  int? statusCode;
  String? statusMessage;
  dynamic? extra;

  OSNetResponse(this.request,
      {this.statusCode, this.data, this.statusMessage, this.extra});

  @override
  String toString() {
    if (data is Map) {
      return json.encode(data);
    }
    return data.toString();
  }
}
